//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) {


        }

    //合并两个有序链表
    public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
        if (list1 == null) {
            return list2;
        }
        if (list2 == null) {
            return list1;
        }
        ListNode dom = new ListNode(0);
        ListNode dom1 = dom;
        ListNode cur1 = list1;
        ListNode cur2 = list2;
        while (cur1 != null && cur2 != null) {
            if (cur1.val < cur2.val) {
                dom.next = cur1;
                cur1 = cur1.next;
            }else {
                dom.next = cur2;
                cur2 = cur2.next;
            }
            dom = dom.next;
        }
        dom.next = cur1 == null ? list2 : cur1;
        return dom;

    }
}
